M=require("ming_node");

app=M.server()
app.listen(8090)
app.set("views",".");

CONFIG={
    "appid": "wx0f012ab2b8db902d",
    "appsecret": "89f1f204691863715cc18e9e0439c069",
}

/**
 * 只有在特定机器能访问
 * @returns {Promise<void>}
 */
//https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx0f012ab2b8db902d&secret=89f1f204691863715cc18e9e0439c069

async function main(){
    const openid="oxIzxsnNRFN5O37eQzKnAU_HDdvU"
    const appid = CONFIG.appid;
    const secret = CONFIG.appsecret;
    const url1 = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + appid + '&secret=' + secret;
    r1= await  M.get(url1)
    let access_token=r1.access_token;
    const url2 = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' + access_token + '&openid=' + openid + '&lang=zh_CN';
    console.log("url2==>",url2)
    r2=await  M.get(url2)
    console.log(r2)
}

main()
